﻿
<script>
    var allVals = [];

    $(document).ready(function () {
        $("#ui-datepicker-div").hide();
        Cancel();
    });


    function AddLinks() {


        //$('#Existingrecordstable :checked').each(function () {
        //    allVals.push($(this).val());
        //});

        Link(allVals);
    }
    function AddLinkInfo() {
        $('#Existingrecordstable :checked').each(function () {
            allVals.push($(this).val());
        });

        $("#RecordList").hide();

        // $("#LinkInfo").show();

        $("#LinkInfo").attr("style", "display: block")
    }
    function Cancel() {
        $("#RecordList").show();

        //$("#LinkInfo").hide();
        $("#LinkInfo").attr("style", "display: none")
        clearLinkInfo();

    }
    function clearLinkInfo() {
        $("#type1").attr('checked', false);
        $("#type2").attr('checked', false);
        $("#type3").attr('checked', false);
        $("#type4").attr('checked', false);
        $("#tentativerelation").attr('checked', false);
        $("#relationtosource").val("");
        $("#contactdateestimate").attr('checked', false);
        $("#contactdate").val("");
        $("#ui-datepicker-div").hide();
    }
    
    function Link(AllVals) {

       
        var Date_Of_Last_Contact = $("#contactdate").val();
        var Relation_To_Source = $("#relationtosource").val();

        if ($('#contactdateestimate').is(":checked")) {
            var Date_Is_Estimated = true;
        }
        else {
            var Date_Is_Estimated = false;
        }
        if ($('#type1').is(":checked")) {
            var Contact_Type_Opt1 = true;
        }
        else {
            var Contact_Type_Opt1 = false;
        }
        if ($('#type2').is(":checked")) {
            var Contact_Type_Opt2 = true;
        }
        else {
            var Contact_Type_Opt2 = false;
        }
        if ($('#type3').is(":checked")) {
            var Contact_Type_Opt3 = true;
        }
        else {
            var Contact_Type_Opt3 = false;
        }
        if ($('#type4').is(":checked")) {
            var Contact_Type_Opt4 = true;
        }
        else {
            var Contact_Type_Opt4 = false;
        }
        if ($('#tentativerelation').is(":checked")) {
            var Tentative_Relation = true;
        }
        else {
            var Tentative_Relation = false;
        }




        $.ajax({
            url: '@Url.Action("Link", "Home")' + '?FromResponseId=' + $("#FROM_RESPONSEID_HIDDEN").val(),
            type: 'POST',
            cache: false,
            traditional: true,
            data: JSON.stringify({ ToResponseIds: AllVals, DateOfLastContact: Date_Of_Last_Contact, DateIsEstimated: Date_Is_Estimated, ContactTypeOpt1: Contact_Type_Opt1, ContactTypeOpt2: Contact_Type_Opt2, ContactTypeOpt3: Contact_Type_Opt3, ContactTypeOpt4: Contact_Type_Opt4, TentativeRelationship: Tentative_Relation, RelationToCase: Relation_To_Source }),
            contentType: 'application/json; charset=utf-8',
            success: successFunc,
            error: errorFunc
        });
        //                    $.ajaxSetup({ cache: false });
        function successFunc(data, status) {
            $("#LinkInfo").attr("style", "display: none");
            $("#LinkExistingdialog").dialog("close");

            ReadLinkResponses($("#LinkFormId_HIDDEN_0").val(), '@Session["PageNumber"]', '', '', $("#FROM_RESPONSEID_HIDDEN").val());
        }
        function errorFunc() {
            alert('error');
        }


    }
    function EnableButton() {
        $('#AddLinkInfo').removeAttr('disabled');

    }


</script>
<script>
    $(function () {
        $("#contactdate").datepicker();
    });
    $(".ui-dialog-titlebar-close").click(function () {
       
        $("#ui-datepicker-div").hide();
        $("#LinkExistingdialog").hide();
    });
    function ShowDatePicker() {

        $("#ui-datepicker-div").show();
    }
</script>
<div id="formtitle" class="formtitle">
    <h2 class="surveyTitle" style="line-height: 120%;">
        Relationship Information
    </h2>
    @*<p><span style="font-size:11pt; font-weight: bold; font-variant:small-caps;">Chosen Case:</span> <span style="font-size:11pt; font-weight: bold;">Last Name, OtherName</span> &nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size:11pt; font-weight: bold; font-variant:small-caps;"> Age:</span><span style="font-size:11pt; font-weight: bold;">23</span></p>*@
</div>
<div style="clear: both;"></div>
<input type="text" style="width: 0; height: 0; top: -1000px; position: absolute;" />
<form>
    <div>
        <label for="contactdate">Date of last contact:</label><br />

        <input id="contactdate" name="contactdate" onclick="ShowDatePicker();" value="" type="text" style="width: 150px;">

    </div>
    <div style="margin-top:5px;">

        <label class="checkbox-label" for="contactdateestimate"><input id="contactdateestimate" type="checkbox" /> Contact date is estimated</label>
    </div>
    <div style="margin-top:15px;">
        <label for="relationtosource">Relationship of source case to case:</label><br />
        <input id="relationtosource" type="text" style="width: 400px;" />
    </div>
    <div style="margin-top:5px;">

        <label class="checkbox-label" for="tentativerelation"><input id="tentativerelation" type="checkbox" /> Tentative relationship</label>
    </div>
    <div style="margin-top:15px;">
        <label>Contact type (select all that apply:)</label><br /><br />

        <label class="checkbox-label" for="type1"><input id="type1" type="checkbox" /> 1 - Touched the body fluids of the case (blood, vomit, saliva, urine, feces)</label><br />

        <label class="checkbox-label" for="type2"><input id="type2" type="checkbox" /> 2 - had direct physical contact with the body of the case (alive or dead)</label><br />

        <label class="checkbox-label" for="type3"><input id="type3" type="checkbox" /> 3 - Touched or shared the linens, clothes, or dishes/utensils of the case</label><br />

        <label class="checkbox-label" for="type4"><input id="type4" type="checkbox" /> 4 - Slept, ate or spent time in the same household or room as the case</label>
    </div>
    
</form>